<template>
  <div class="app-container">
    <el-form
      class="grid column_4"
      ref="queryForm"
      size="small"
      label-width="140px"
      :model="formState"
    >
      <el-form-item class="grid-item mr_unset" label="证件号码" prop="idNumber">
        <el-input v-model="formState.idNumber" placeholder="请输入证件号码" />
      </el-form-item>
      <el-form-item class="grid-item mr_unset" label="姓名" prop="name">
        <el-input v-model="formState.name" placeholder="请输入姓名" />
      </el-form-item>
      <el-form-item class="grid-item mr_unset" label="性别" prop="gender">
        <el-select
          v-model="formState.gender"
          class="input-block"
          placeholder="请选择性别"
        >
          <el-option
            v-for="item in genders"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item class="grid-item mr_unset" label="年龄" prop="age">
        <el-input v-model="formState.age" placeholder="请输入年龄" />
      </el-form-item>
      <el-form-item
        class="grid-item mr_unset"
        label="现住完整详细地址"
        prop="address"
      >
        <el-input
          v-model="formState.address"
          placeholder="请输入现住完整详细地址"
        />
      </el-form-item>
      <el-form-item class="grid-item mr_unset" label="民族" prop="nation">
        <el-select
          v-model="formState.nation"
          class="input-block"
          placeholder="请选择民族"
        >
          <el-option
            v-for="item in nations"
            :key="item.id"
            :label="item.nation"
            :value="item.id"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item
        class="grid-item mr_unset"
        label="多人群分类"
        prop="audienceCategory"
      >
        <el-select
          v-model="formState.audienceCategory"
          class="input-block"
          placeholder="请选择多人群分类"
        >
          <el-option
            v-for="item in types"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item
        class="grid-item mr_unset"
        label="本人联系电话"
        prop="contactNumber"
      >
        <el-input
          v-model="formState.contactNumber"
          placeholder="请输入本人联系电话"
        />
      </el-form-item>
      <el-form-item class="grid-item mr_unset" label="学校" prop="school">
        <el-input v-model="formState.school" placeholder="请输入学校" />
      </el-form-item>
      <el-form-item class="grid-item mr_unset" label="班级" prop="className">
        <el-input v-model="formState.className" placeholder="请输入班级" />
      </el-form-item>
      <el-form-item
        class="grid-item mr_unset"
        label="寺庙名称"
        prop="templeName"
      >
        <el-input v-model="formState.templeName" placeholder="请输入寺庙名称" />
      </el-form-item>
      <el-form-item
        class="grid-item mr_unset"
        label="是否新增患者"
        prop="isAdded"
      >
        <el-select
          v-model="formState.isAdded"
          class="input-block"
          placeholder="请选择是否新增患者"
        >
          <el-option
            v-for="item in status"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item
        class="grid-item mr_unset"
        label="实际筛查时间"
        prop="screeningTime"
      >
        <el-date-picker
          v-model="formState.screeningTime"
          class="input-block"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item class="grid-item mr_unset">
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="submitForm('queryForm')"
          >搜索</el-button
        >
        <el-button
          icon="el-icon-refresh"
          size="mini"
          @click="resetForm('queryForm')"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          v-hasPermi="['system:role:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          v-hasPermi="['system:role:export']"
          >导出筛查患者</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          v-hasPermi="['system:role:export']"
          >导出筛查记录</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          plain
          icon="el-icon-plus"
          size="mini"
          v-hasPermi="['system:role:export']"
          >导入</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-input size="mini" placeholder="请输入证件号"></el-input>
      </el-col>
      <right-toolbar

      ></right-toolbar>
    </el-row>

    <el-table>
      <el-table-column label="编号" prop="roleId" width="120" />

      <el-table-column
        label="证件号码"
        prop=""
        :show-overflow-tooltip="true"
        width="150"
      />
      <el-table-column
        label="是否新增"
        prop=""
        :show-overflow-tooltip="true"
        width="150"
      />
      <el-table-column
        label="是否筛查"
        prop=""
        :show-overflow-tooltip="true"
        width="150"
      />

      <el-table-column
        label="姓名"
        prop=""
        :show-overflow-tooltip="true"
        width="150"
      />

      <el-table-column
        label="地区"
        prop=""
        :show-overflow-tooltip="true"
        width="150"
      />
      <el-table-column
        label="性别"
        prop=""
        :show-overflow-tooltip="true"
        width="150"
      />
      <el-table-column
        label="年龄"
        prop=""
        :show-overflow-tooltip="true"
        width="150"
      />
      <el-table-column
        label="第一人群分类"
        prop=""
        :show-overflow-tooltip="true"
        width="150"
      />
      <el-table-column
        label="多人群分类"
        prop=""
        :show-overflow-tooltip="true"
        width="150"
      />
      <el-table-column
        label="名族"
        prop=""
        :show-overflow-tooltip="true"
        width="150"
      />
      <el-table-column
        label="电话号"
        prop=""
        :show-overflow-tooltip="true"
        width="150"
      />
      <el-table-column
        label="学校"
        prop=""
        :show-overflow-tooltip="true"
        width="150"
      />
      <el-table-column
        label="班级"
        prop=""
        :show-overflow-tooltip="true"
        width="150"
      />
      <el-table-column
        label="计划筛查时间"
        prop=""
        :show-overflow-tooltip="true"
        width="150"
      />
      <el-table-column
        label="备注"
        prop=""
        :show-overflow-tooltip="true"
        width="150"
      />
      <el-table-column
        label="操作"
        fixed="right"
        prop=""
        :show-overflow-tooltip="true"
        width="150"
      />
    </el-table>
  </div>
</template>

<script>
import { genders, status, types } from "@/model/options";
import { getNations } from "@/api/common";
import { scrub } from '@/filter/index';

export default {
  name: "Unseda",
  data() {
    return {
      genders,
      status,
      types,
      nations: [],
      formState: {
        idNumber: '',
        name: '',
        gender: '',
        age: '',
        address: '',
        nation: '',
        audienceCategory: '',
        contactNumber: '',
        school: '',
        className: '',
        templeName: '',
        isAdded: '',
        screeningTime: '',
      },
      list: [],
      pagination: {},
    };
  },

  methods: {
    async getTableDate() {
      const { list, pagination } = await getUnsedaList();
      console.log("result", list, pagination);
      this.list = list;
      this.pagination = pagination;
    },
    async getData() {
      this.nations = (await getNations()) || [];
    },
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          console.log('valid', valid, this.formState, scrub(this.formState));
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
  },
  mounted() {
    this.getData();
    this.getTableDate();
  },
};
</script>
